<template>
    <div>
        <el-container>
            <el-header class="header-all">
                <!-- 查询区域 -->
                <div style="display: inline;">
                    <!-- <el-select placeholder="请选择动力" v-model="car.powertype">
                        <el-option v-for="item in myCar" :key="item.powertype" :label="item.powertype"
                            :value="item.powertype"></el-option>
                    </el-select> -->
                    <el-button type="primary" class="but-select" @click="select">搜索</el-button>
                </div>
            </el-header>
            <el-main>
                <el-table :data="employeeList" v-loading="loading" ref="employeeList" stripe>
                    <el-table-column prop="dept" width="160px" label="部门" align="center"></el-table-column>
                    <el-table-column prop="empno" width="220px" label="编号" align="center"></el-table-column>
                    <el-table-column prop="id" width="140px" label="id" align="center"></el-table-column>
                    <el-table-column prop="namecn" width="220px" label="姓名" align="center"></el-table-column>
                    <el-table-column width="260px" label="操作" align="center">
                        <template slot-scope="scope">
                            <el-button type="success" plain @click="upd(scope.$index, scope.row)">修改</el-button>
                            <el-button type="danger" plain @click="del(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-main>
        </el-container>
    </div>
</template>

<script>
export default {
    name: "employee",
    data() {
        return {
            employeeList: [],
            employee: {
                dept: "",
                empno: "",
                id: "",
                namecn: "",
            },
            myCar: "",
            loading: false,
        };
    },
    created() {
        this.postJsonCar()
        this.postJsonDl()
    },
    methods: {
        postJsonCar() {
            console.log("进入加载列表数据方法")
            var rul = "http://121.37.241.58:8883/logic/baseInfo/employee/find"
            this.$axios.get(rul).then(re => {
                // console.log(re.data)
                this.employeeList = re.data
            });
        },
        postJsonDl() {
            console.log("进入加载下拉框数据方法")
            var rul = "http://121.37.241.58:8883/logic/baseInfo/employee/deptList"
            this.$axios.get(rul).then(re => {
                console.log("-------")
                // console.log(re.data)
                this.myCar = re.data
                this.myCar.push({ powertype: "全部" })
            });
        },
        select() {
            console.log(this.car.powertype);
            console.log("进入数据搜索列表数据方法")
            // 默认查询接口
            var rul = "http://121.37.241.58:8883/logic/baseInfo/sysUser/find?namecn=1"

            // 根据下列选项除全部以外的信息查询接口
            if (this.user.role != "全部") {
                rul = "http://121.37.241.58:8883/logic/baseInfo/sysUser/find?role=" + this.user.role
            }

            this.$axios.get(rul).then(re => {
                console.log(re.data)
                this.UsersList = re.data
            });
        }
    }
}
</script>

<style scoped>
.header-all {
    padding: 0px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
</style>